﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Drawing;

namespace SIAR_mobile.Util
{
    public partial class TransparentLabel : Control
    {
        public TransparentLabel() {
            this.TextChanged += new System.EventHandler(this.alterouTexto);
        }

        public void alterouTexto(object sender, EventArgs e) {
            this.Invalidate();
        }

        protected override void OnPaintBackground(PaintEventArgs e) {
        }

        private bool bPaintOnce = false;

        protected override void OnPaint(PaintEventArgs e) {
            if (!bPaintOnce) {
                bPaintOnce = true;
                this.Visible = false;
                this.Parent.Invalidate(this.Bounds);
                this.Parent.Update();
                this.Visible = true;
                return;
            }
            else {
                bPaintOnce = false;
                Graphics g = e.Graphics;
                Font font = this.Font;
                SolidBrush brush = new SolidBrush(this.ForeColor);
                g.DrawString(this.Text, font, brush, 1, 1);
                g.Dispose();
            }
        }
    }
}

